import random
from eden.ann.neurons import Neuron

if __name__ == "__main__":
	Neuron.LEARNING_FACTOR = 1
	inputNeuron = Neuron()
	outputNeuron = Neuron()
	outputNeuron.addInput(inputNeuron, 0.1)
	for i in range(300):
		input = random.choice((0, 1))
		expected = 0.5 if input == 0 else 0
		inputNeuron.setVoltage(input)
		outputNeuron.run()
		output = outputNeuron.getVoltage()
		weight = outputNeuron.getInputs()[inputNeuron]
		outputNeuron.bp(expected)
		print('STEP#' + str(i) + ': ' + str(input) + ' --> ' + str(output) + ' (weight=' + str(weight) + ')')